package com.ruoyi.yh.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yh.domain.YiBloodInfo;
import com.ruoyi.yh.service.IYiBloodInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 姓氏管理Controller
 * 
 * @author ruoyi
 * @date 2022-03-14
 */
@RestController
@RequestMapping("/yh/bloodinfo")
public class YiBloodInfoController extends BaseController
{
    @Autowired
    private IYiBloodInfoService yiBloodInfoService;

    /**
     * 查询姓氏管理列表
     */
    @PreAuthorize("@ss.hasPermi('yh:bloodinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(YiBloodInfo yiBloodInfo)
    {
        startPage();
        List<YiBloodInfo> list = yiBloodInfoService.selectYiBloodInfoList(yiBloodInfo);
        return getDataTable(list);
    }
    /**
     * 查询姓氏管理列表
     */
    @PreAuthorize("@ss.hasPermi('yh:bloodinfo:list')")
    @GetMapping("/listAll")
    public AjaxResult listAll(YiBloodInfo yiBloodInfo)
    {
        List<YiBloodInfo> list = yiBloodInfoService.selectYiBloodInfoList(yiBloodInfo);
        return AjaxResult.success(list);
    }

    /**
     * 导出姓氏管理列表
     */
    @PreAuthorize("@ss.hasPermi('yh:bloodinfo:export')")
    @Log(title = "姓氏管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YiBloodInfo yiBloodInfo)
    {
        List<YiBloodInfo> list = yiBloodInfoService.selectYiBloodInfoList(yiBloodInfo);
        ExcelUtil<YiBloodInfo> util = new ExcelUtil<YiBloodInfo>(YiBloodInfo.class);
        util.exportExcel(response, list, "姓氏管理数据");
    }

    /**
     * 获取姓氏管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('yh:bloodinfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(yiBloodInfoService.selectYiBloodInfoById(id));
    }

    /**
     * 新增姓氏管理
     */
    @PreAuthorize("@ss.hasPermi('yh:bloodinfo:add')")
    @Log(title = "姓氏管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YiBloodInfo yiBloodInfo)
    {
        return toAjax(yiBloodInfoService.insertYiBloodInfo(yiBloodInfo));
    }

    /**
     * 修改姓氏管理
     */
    @PreAuthorize("@ss.hasPermi('yh:bloodinfo:edit')")
    @Log(title = "姓氏管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YiBloodInfo yiBloodInfo)
    {
        return toAjax(yiBloodInfoService.updateYiBloodInfo(yiBloodInfo));
    }

    /**
     * 删除姓氏管理
     */
    @PreAuthorize("@ss.hasPermi('yh:bloodinfo:remove')")
    @Log(title = "姓氏管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yiBloodInfoService.deleteYiBloodInfoByIds(ids));
    }
}
